/**
 * 用户路由
 * 处理用户相关的API请求
 */
const express = require('express');
const router = express.Router();
const { protect } = require('../middleware/authMiddleware');
const { 
  getUserProfile,
  updateUserProfile,
  updateAvatar,
  searchUsers
} = require('../controllers/userController');
const upload = require('../middleware/uploadMiddleware');

// 用户个人资料
router.route('/profile')
  .get(protect, getUserProfile) // 获取用户个人资料
  .put(protect, updateUserProfile); // 更新用户个人资料

// 更新头像
router.route('/avatar')
  .put(protect, upload.single('avatar'), updateAvatar);

// 搜索用户
router.route('/search')
  .get(protect, searchUsers);

module.exports = router; 